package DynamicProxy.proxyDemo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * create by mwh 2021-11-12
 **/

public class ApiTimeProxy implements InvocationHandler {
    private Object apiTime;

    public ApiTimeProxy(Object apiTime){

       this.apiTime = apiTime;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        long starttime = System.currentTimeMillis();
        System.out.println("api开始时间为："+starttime);
        method.invoke(apiTime,args);
        long endtime = System.currentTimeMillis();
        System.out.println("api结束时间为："+endtime);
        System.out.println("api请求时间为："+(endtime-starttime));
        return null;
    }
}
